package com.sls.game.dao.xingxitian.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.xingxitian.XingGameAreaSrvDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.xingqitian.XingGameAreaSrvInfo;

/**
 * 
 * @description
 * @author Wangxuegang
 * @date 2012-12-22
 */
@Repository("xingGameAreaSrvDAO")
public class XingGameAreaSrvDAOImpl extends SuperDAO<XingGameAreaSrvInfo>
		implements XingGameAreaSrvDAO {

	@Override
	public void insert(XingGameAreaSrvInfo info) {
		this.getSqlSession().insert("mybatis.xml.XingAreaServerMapper.insert",
				info);
	}

	@Override
	public Pagination<XingGameAreaSrvInfo> queryAreaServerInfo(
			XingGameAreaSrvInfo info) {
		Pagination<XingGameAreaSrvInfo> paginationList = null;
		Integer rowCount = queryRowCount(info);
		info.calculate();
		List<XingGameAreaSrvInfo> list = queryParvalueInfoList(info);
		paginationList = this.queryPagination(rowCount, list, info);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(XingGameAreaSrvInfo info) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.XingAreaServerMapper.queryRowCount", info);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<XingGameAreaSrvInfo> queryParvalueInfoList(
			XingGameAreaSrvInfo info) {
		List<XingGameAreaSrvInfo> list = this.getSqlSession().selectList(
				"mybatis.xml.XingAreaServerMapper.queryXQTAreaServerInfoList",
				info);
		return list;
	}

	/**
	 * 查询areaId和srvId
	 * 
	 * @param info
	 * @return
	 */
	@Override
	public XingGameAreaSrvInfo queryAreaAndSrv(XingGameAreaSrvInfo info) {
		XingGameAreaSrvInfo areaSrvinfo = null;
		areaSrvinfo = this.getSqlSession().selectOne(
				"mybatis.xml.XingAreaServerMapper.queryAreaAndSrv", info);
		return areaSrvinfo;
	}

	/**
	 * 根据游戏文件对应编号,查询区域
	 * 
	 * @param gametype1
	 * @return
	 */
	@Override
	public List<XingGameAreaSrvInfo> queryGameAreaBygametype1(String gametype1) {
		List<XingGameAreaSrvInfo> list = null;
		list = this.getSqlSession().selectList(
				"mybatis.xml.XingAreaServerMapper.queryGameAreaBygametype1",
				gametype1);
		return list;
	}

	/**
	 * 根据游戏文件对应编号,查询服务器
	 * 
	 * @param gametype1
	 * @return
	 */
	@Override
	public List<XingGameAreaSrvInfo> queryGameSrvBygametype1(
			XingGameAreaSrvInfo info) {
		List<XingGameAreaSrvInfo> list = null;
		list = this.getSqlSession().selectList(
				"mybatis.xml.XingAreaServerMapper.queryGameSrvBygametype1",
				info);
		return list;
	}

	/**
	 * 记录详情
	 * 
	 * @param id
	 * @return
	 */
	@Override
	public XingGameAreaSrvInfo queryGameAreaSrvById(String id) {
		XingGameAreaSrvInfo info = null;
		info = this.getSqlSession().selectOne(
				"mybatis.xml.XingAreaServerMapper.queryGameAreaSrvById", id);
		return info;
	}

	@Override
	public List<XingGameAreaSrvInfo> queryByGameType(String gametype1) {
		List<XingGameAreaSrvInfo> list  = this.getSqlSession().selectList(
				"mybatis.xml.XingAreaServerMapper.queryByGameType",
				gametype1);
		return list;
	}

	@Override
	public void updateAS(XingGameAreaSrvInfo info) {
		this.getSqlSession().update("mybatis.xml.XingAreaServerMapper.updateAS", info);
	}
}
